package com.yeung.actions;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.support.ResourceBundleMessageSource;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.Locale;

import static com.yeung.actions.ServiceResult.SUCCESS;

@Controller
public class I18NTest {
    @Autowired
    private ResourceBundleMessageSource messageSource;


    //    获取国际化资源文件locale对应的消息
    @RequestMapping("/i18n")
    public String testI18n(Locale locale) {
        String message = messageSource.getMessage("i18n.userName", null, locale);
        System.out.println(message);
        return "i18n";
    }
}
